package com.taxi.service;

import com.taxi.remote.MapDirectionClient;
import com.taxi.request.ForecastPriceDOT;
import com.taxi.response.DirectionResponse;
import com.taxi.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author: aniu
 * @Date: 2023/9/25
 * @ClassName: DirectionService
 * @Description: Write class functionality and purpose here.
 * @Version: 1.0
 */
@Service
public class DirectionService {

    @Autowired
    private MapDirectionClient mapDirectionClient;

    /**
     * 根据起点经纬度和终点经纬度获取距离(米)和时长(分钟)
     * @param forecastPriceDOT
     * @return
     */
    public Result driving(ForecastPriceDOT forecastPriceDOT) {
        // 获取属性值
        String depLongitude = forecastPriceDOT.getDepLongitude();
        String depLatitude = forecastPriceDOT.getDepLatitude();
        String destLongitude = forecastPriceDOT.getDestLongitude();
        String destLatitude = forecastPriceDOT.getDestLatitude();
        //调用地图接口
        DirectionResponse direction = mapDirectionClient.direction(depLongitude, depLatitude, destLongitude, destLatitude);

        return Result.ok(direction);
    }
}
